/**
 * Created by kangdaye on 16/5/15.
 */
app.controller('distributorDrawCtr',["$scope","$rootScope","confirmFactory","distributorDrawService", function($scope,$rootScope,confirmFactory,distributorDrawService) {
    var now = new Date(),                                                //当前日期
        hours = now.getHours();

    $scope.getData = {
        channel : 'WECHAT',
        radio : 3,
        account:""
    };

    $scope.ifDraw = now.getDay() === 1 && (hours  > 8 && hours < 20);

    if(!$rootScope.userInfoData.certifiedInfo || $rootScope.userInfoData.certifiedInfo.status != 1){
        confirmFactory({
            scope:$scope,
            text:'请先验证身份证或等待审核通过!',
            option:{
                go:function(){
                    location.href = $rootScope.prefix + 'userContent/setUp/identity.html';
                },
                close:function(){
                    window.history.back();
                }
            }
        });
    }

    $scope.submit = function(){
        if($scope.getData.radio==0){
            $scope.getData.channel="BALANCE";
        }else if($scope.getData.radio==1){
            $scope.getData.channel="WECHAT";
        }else if($scope.getData.account.length>0){
            $scope.getData.channel="ALIPAY";
        }
        distributorDrawService.apply($scope.getData,function(){
            location.href = $rootScope.prefix + 'userContent/distributor/distributorRecord.html';
        });
    };
}]);
